﻿using System;
using System.Globalization;
using mal.WP7.Framework.Helpers;
using Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace mal.WP7.Framework.UnitTest
{
    [TestClass]
    public class DateTimeHelperTest : SilverlightTest
    {
        #region GetFirstDayOfWeek
        [TestMethod]
        public void GetFirstDayOfWeekTestSunday()
        {
            DateTime expected;
            DateTime actual;
            DateTime date;

            date = new DateTime(2011, 11, 20);
            expected = new DateTime(2011, 11, 20);
            actual = DateTimeHelper.GetFirstDayOfWeek(date, new CultureInfo("en-us"));
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetFirstDayOfWeekTestSaturday()
        {
            DateTime expected;
            DateTime actual;
            DateTime date;

            date = new DateTime(2011, 11, 19);
            expected = new DateTime(2011, 11, 13);
            actual = DateTimeHelper.GetFirstDayOfWeek(date, new CultureInfo("en-us"));
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetFirstDayOfWeekTestThursday()
        {
            DateTime expected;
            DateTime actual;
            DateTime date;

            date = new DateTime(2011, 11, 17);
            expected = new DateTime(2011, 11, 13);
            actual = DateTimeHelper.GetFirstDayOfWeek(date, new CultureInfo("en-us"));
            Assert.AreEqual(expected, actual);
        } 
        #endregion

        #region GetFirstDayOfMonth
        [TestMethod]
        public void GetFirstDayOfMonthTestFirst()
        {
            DateTime expected;
            DateTime actual;
            DateTime date;

            date = new DateTime(2011, 11, 1);
            expected = new DateTime(2011, 11, 1);
            actual = DateTimeHelper.GetFirstDayOfMonth(date);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetFirstDayOfMonthTestFiveteen()
        {
            DateTime expected;
            DateTime actual;
            DateTime date;

            date = new DateTime(2011, 11, 15);
            expected = new DateTime(2011, 11, 1);
            actual = DateTimeHelper.GetFirstDayOfMonth(date);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetFirstDayOfMonthTestLastDay()
        {
            DateTime expected;
            DateTime actual;
            DateTime date;

            date = new DateTime(2011, 11, 30);
            expected = new DateTime(2011, 11, 1);
            actual = DateTimeHelper.GetFirstDayOfMonth(date);
            Assert.AreEqual(expected, actual);
        } 
        #endregion

        #region GetFirstDayOfYear
        [TestMethod]
        public void GetFirstDayOfYearTestFirst()
        {
            DateTime expected;
            DateTime actual;
            DateTime date;

            date = new DateTime(2011, 1, 1);
            expected = new DateTime(2011, 1, 1);
            actual = DateTimeHelper.GetFirstDayOfYear(date);
            Assert.AreEqual(expected, actual);
        } 
        
         [TestMethod]
        public void GetFirstDayOfYearTestOther()
        {
            DateTime expected;
            DateTime actual;
            DateTime date;

            date = new DateTime(2011, 3, 17);
            expected = new DateTime(2011, 1, 1);
            actual = DateTimeHelper.GetFirstDayOfYear(date);
            Assert.AreEqual(expected, actual);
        } 

        [TestMethod]
        public void GetFirstDayOfYearTestLastDay()
        {
            DateTime expected;
            DateTime actual;
            DateTime date;

            date = new DateTime(2011, 12, 31);
            expected = new DateTime(2011, 1, 1);
            actual = DateTimeHelper.GetFirstDayOfYear(date);
            Assert.AreEqual(expected, actual);
        } 
        #endregion

      
    }
}
